#include <bits/stdc++.h>
using namespace std;
int buf[3];
int main() {
  for (int i = 0; i < 3; ++i) cin >> buf[i];
  sort(buf, buf + 3);
  for (int i = 0; i < 3; ++i) {
    char c;
    cin >> c;
    cout << buf[int(c - 'A')] << ' ';
  }
  cout << endl;
}
